/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tk.eigh.ksvg.renderer.structure;


import tk.eigh.ksvg.renderer.SVGStructureRenderer;
import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import ksvg.shape.Circle;
import ksvg.structure.Document;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
import org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils;
import tk.eigh.ksvg.SVG;
import tk.eigh.ksvg.renderer.SVGRenderer;

/**
 *
 * @author nt
 */
@JSFRenderer(renderKitId="SVG",type="structure.SVGDocumentRenderer",family="structure.Container")
public class SVGDocumentRenderer extends SVGStructureRenderer{

    protected final static String TAG_NAME = "svg";
    @Override
    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        super.encodeBegin(context, component);
        
        ResponseWriter writer = context.getResponseWriter();
        Document document = (Document) component;
        
        writer.startElement(TAG_NAME, component);
        writer.writeAttribute(SVG.XMLNS_ATTR_NAME, SVG.XMLNS, null);
        writer.writeAttribute(SVG.VERSION_ATTR, document.getVersion(), null);
        //renderCommonAttributes(writer, document, context);
        HtmlRendererUtils.renderHTMLAttributes(writer, component, SVG.DOCUMENT_ELEMENT_PROPERTIES);
        HtmlRendererUtils.renderHTMLAttributes(writer, component, SVG.DOCUMENT_EVENT_ATTRIBUTES);
    }

    @Override
    public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
        super.encodeEnd(context, component);
        context.getResponseWriter().endElement(TAG_NAME);
    }
    
}
